<template>
  <div>
    <HomeHeader></HomeHeader>
    <TypeNav></TypeNav>
    <div class="box">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">盛世绿能招投标系统</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: '/noticeList' }">招标公告</el-breadcrumb-item>
        <el-breadcrumb-item >标案竞价</el-breadcrumb-item>
      </el-breadcrumb>
      <div style="width: 1400px;margin: 20px auto 0;background-color: #FFFFFF;">
        <el-form ref="bidForm" v-loading="loading" :model="bidPrice">
          <div style="padding: 10px 100px">
            <p style="font-size: 18px;text-align: center;"><span style="color: red;">竞标室-标号({{ bidPrice.sCode}})&nbsp;--&nbsp;{{ bidPrice.sName}}</span> </p>
            <el-descriptions class="margin-top" size="medium" :column="3" border>
              <el-descriptions-item label-style="text-align: center;height:35px;">
                <template slot="label">
                  招标公司：
                </template>
                <el-input type="text" v-model="bidPrice.sUnit" readonly/>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;">
                <template slot="label">
                  开始时间：
                </template>
                <span style="padding-left: 15px">{{parseTime(bidPrice.uKaiTime, '{y}-{m}-{d} {h}:{i}:{s}')}}</span>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;">
                <template slot="label">
                  结束时间：
                </template>
                <span style="padding-left: 15px">{{parseTime(this.uKaiEndTime, '{y}-{m}-{d} {h}:{i}:{s}')}}</span>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;">
                <template slot="label">
                  招标方式：
                </template>
                <el-input type="text" value="公开招标"  v-if="bidPrice.sWay === 1" readonly/>
                <el-input type="text" value="邀请招标"  v-if="bidPrice.sWay === 2" readonly/>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;">
                <template slot="label">
                  最小降幅：
                </template>
                <span style="padding-left: 15px">{{bidPrice.minDecline}}&nbsp;%</span>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;">
                <template slot="label">
                  每次最大降幅：
                </template>
                <span style="padding-left: 15px">{{bidPrice.maxDecline}}&nbsp;%(最小降幅{{multiple}}倍)</span>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;">
                <template slot="label">
                  竞标类别：
                </template>
                <el-input type="text" v-model="bidPrice.biddingCategory" clearable readonly/>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;">
                <template slot="label">
                  币别：
                </template>
                <el-input type="text" v-model="bidPrice.currencyCategory" clearable readonly/>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;">
                <template slot="label">
                  相同报价排名：
                </template>
                <el-input type="text" v-model="bidPrice.sorted" clearable readonly/>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;">
                <template slot="label">
                  延长时间：
                </template>
                <span style="padding-left: 15px">{{bidPrice.extendTime}}&nbsp;分钟</span>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;">
                <template slot="label">
                  延时次数：
                </template>
                <span style="padding-left: 15px">{{bidPrice.extendCount}}&nbsp;次</span>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;">
                <template slot="label">
                  起始价：
                </template>
                <span style="padding-left: 15px">{{bidPrice.startPrice}}&nbsp;{{bidPrice.currencyCategory}}</span>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;" span="3">
                <template slot="label">
                  竞价类别：
                </template>
                <el-input type="text" v-model="bidPrice.priceCategory" clearable readonly/>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;" span="1.5">
                <template slot="label">
                  小数保留位数：
                </template>
                <span style="padding-left: 15px">{{bidPrice.decimalPlaces}}&nbsp;位</span>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;" span="1.5">
                <template slot="label">
                  小数舍弃规则：
                </template>
                <el-input type="text" v-model="bidPrice.decimalRule" clearable readonly/>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;" span="3">
                <template slot="label">
                  竞标方式：
                </template>
                <el-input type="text" v-model="bidPrice.biddingMethod" clearable readonly/>
              </el-descriptions-item>
              <el-descriptions-item label-style="text-align: center;height:35px;" span="3">
                <template slot="label">
                  延时规则：
                </template>
                <el-input type="text" v-model="bidPrice.extendTimeRule" style="height: 35px;" clearable readonly/>
              </el-descriptions-item>
            </el-descriptions>
          </div>
          <div style="padding:0 100px;text-align: center">
            <p style="font-size: 18px;text-align: center;font-weight: bold;">距离结束时间：
              <span style="color: red;">{{ days }}天{{ hours }}时{{ minutes }}分{{ seconds }}秒</span>
              <el-button style="margin-left: 30px;" size="mini" type="danger" @click="refreshCountdown">刷新</el-button>
            </p>
            <div class="content">
              <h2><i class="fas fa-check-circle"></i>{{ notificationText }}</h2>
            </div>
          </div>
        </el-form>
        <div style="padding-top:20px;border-bottom:0px;padding-left:100px;padding-right:100px;text-align: center">
          <span style="color: red;">竞价过程中请勿离开竞价室，以免错过竞价信息。</span>
        </div>
        <el-form style="width: 1200px;margin: 5px auto 0;">
          <div style="padding:0 100px;text-align: center">
            <span style="text-align: center;font-size: 18px;font-weight: bold;">竞标价格</span>
          </div>
          <el-descriptions class="margin-top" size="medium" :column="3" border>
            <el-descriptions-item label-style="text-align: center;height:35px;">
              <template slot="label">
                当前排名：
              </template>
              <span style="padding-left: 15px">{{bidPriceInfo.sorted}}</span>
            </el-descriptions-item>
            <el-descriptions-item label-style="text-align: center;height:35px;">
              <template slot="label">
                累积降幅：
              </template>
              <span style="padding-left: 15px">{{bidPriceInfo.cumulativeDecline}}&nbsp;%</span>
            </el-descriptions-item>
            <el-descriptions-item label-style="text-align: center;height:35px;">
              <template slot="label">
                最终金额：
              </template>
              <span style="padding-left: 15px">{{bidPriceInfo.finalAmount}}&nbsp;({{bidPrice.currencyCategory}})</span>
            </el-descriptions-item>
            <el-descriptions-item label-style="text-align: center;height:35px;" span="3">
              <template slot="label">
                竞价输入：
              </template>
              <div style="padding:5px 0px;text-align: center">
                <p style="margin-right: 355px;;height: 21px;"><span>出价</span><span style="color: red;">(*请输入整数)</span></p>
                <p style="margin-right: 16px;height: 35px;">
                  <span style="font-weight: bold;">{{bidPriceInfo.cumulativeDecline}}&nbsp;%&nbsp;+&nbsp;(&nbsp;{{bidPrice.minDecline}}&nbsp;*&nbsp;</span>
                  <input class="my-input" type="text" v-model="bidPriceInfo.bidMultiple" @keypress="validateNumberInput" @input="handlePriceInput"/>
                  <span style="padding-left: 5px;font-weight: bold;">)&nbsp;%&nbsp;=</span>
                  <input class="my-input-tips" type="text" v-model="bidPriceInfo.bidPriceTips" readonly/>
                  <el-button style="margin-left: 30px;" size="mini" type="danger" @click="submitBidPrice">出价</el-button>
                  <span id="submitTextId" style="padding-left: 15px;color: #e6a23c;font-size:16px;font-weight: bold;" :style="{color: textColor }">{{bidPriceInfo.submitText}}</span>
                </p>
              </div>
            </el-descriptions-item>
          </el-descriptions>
        </el-form>
        <div class="bidding-grid-content">
          <el-table v-loading="loading2" :data="biddingPriceList" style="width: 1200px;margin: 20px auto 0;">
            <el-table-column label="出价序号(次数)" align="center" prop="bjCount" width="200">
              <template slot-scope="scope">
<!--                {{ biddingPriceList.length - scope.$index }}-->
                {{ scope.row.bjCount }}
              </template>
            </el-table-column>
            <el-table-column label="降价幅度" align="center" prop="bjDecline">
              <template slot-scope="scope">
                {{ scope.row.bjDecline }}&nbsp;%
              </template>
            </el-table-column>
            <el-table-column label="竞标金额" :label="currencyCategory" align="center" prop="bjTotal">
              <template slot-scope="scope">
                {{ scope.row.bjTotal }}
              </template>
            </el-table-column>
            <el-table-column label="竞价时间" align="center" prop="createTime"/>
          </el-table>
        </div>
      </div>

      <div slot="footer" class="dialog-footer" style="text-align: center;padding-bottom: 10px">

      </div>
    </div>
    <HomeFloor></HomeFloor>
  </div>
</template>
<script>

import modal from "@/plugins/modal";
import HomeHeader from "@/components/home/HomeHeader";
import TypeNav from "@/components/home/TypeNav";
import HomeFloor from "@/components/home/HomeFloor";
import {findBiddingRule, findBiddingList, findLastTenderQuotation, addTenderQuotation,findProcurementPlan} from "@/api/system/tender";

export default {
  name: 'goBidding',
  components:{
    HomeHeader,
    TypeNav,
    HomeFloor
  },
  data() {
    return {
      getBiddingCount: 0,
      multiple: 1,
      loading: false,
      uKaiTime: '',
      uKaiEndTime: '',
      days: 0,
      hours: 0,
      minutes: 0,
      seconds: 0,
      isEnd: true,
      countdownInterval: null,
      message: '',
      notificationText: '',
      initialTime: 0,
      currencyCategory: '竞标金额(RMB)',
      bidForm: {
        uid: null,
        sid: null,
        hid: JSON.parse(sessionStorage.getItem('bsSupplier')).hid,
      },
      bidPrice: {
        sCode: '',
      },
      bidPriceInfo: {
        sorted: 0,
        cumulativeDecline: 0.0,
        finalAmount:0.0,
        bidMultiple: null,
        bidPriceTips: '',
        submitText: '点击出价',
      },
      textColor: '#e6a23c',
      tenderQuotation: {
        uid: null,
        sid: null,
        hid: JSON.parse(sessionStorage.getItem('bsSupplier')).hid,
        sCode: null,
        aid: null,
        aaCode: null,
        bjDecline: null,
        bjTotal: null,
        bjCount: null,
        hName: null
      },
      loading2: false,
      biddingPriceList: [],
    }
  },
  created() {
    this.bidForm.uid = this.$route.query.uid;
    this.bidForm.sid =this.$route.query.sid;
    this.tenderQuotation.uid = this.$route.query.uid;
    this.tenderQuotation.sid =this.$route.query.sid;
    this.tenderQuotation.aid =this.$route.query.xyId;
    let type =this.$route.query.type;
    if (sessionStorage.getItem("token") == null) {
      modal.alertWarning("注册供应商并登录后竞价")
    } else {
      this.getInfo(this.bidForm.sid);
    }
  },
  methods: {
    reset() {
      this.bidForm = {

      }
    },
    // 取消按钮
    cancel() {
      this.reset();

    },
    getInfo(sid) {
      this.loading = true;
      this.loading2 = true;
      findBiddingRule(sid,this.bidForm.hid).then(response=>{
        this.loading = false;
        if(response.data && response.data.data){
          this.bidPrice = response.data.data;
          this.uKaiTime = this.bidPrice.uKaiTime;
          this.uKaiEndTime = this.bidPrice.uKaiEndTime;
          const otherUKaiTime = this.bidPrice.uKaiTime;
          this.tenderQuotation.sCode = this.bidPrice.sCode;
          this.currencyCategory = '竞标金额(' + this.bidPrice.currencyCategory + ')';
          console.log('1111111111111111111111111111111111111111111111111111111111')
          console.log(this.tenderQuotation)
          const newDate = new Date(otherUKaiTime);
          newDate.setMinutes(newDate.getMinutes() + 30);
          //this.endTime = newDate;
          let max = this.bidPrice.maxDecline;
          let min = this.bidPrice.minDecline;
          this.multiple = this.calculateDecimalRatio(max,min);
          const now = new Date().getTime();
          const otherDate = new Date(otherUKaiTime).getTime();
          if(now > otherDate){
            this.startCountdown(this.uKaiEndTime);
          }else{
            this.showNotification('未到竞标时间');
          }
        }
      });
      this.findLastQuotation(sid,this.bidForm.hid);
      this.findProcurementPlanInfo(this.tenderQuotation.aid);
    },
    findLastQuotation(sid,hid){
      findLastTenderQuotation(sid,hid).then(response=>{
        if(response.data && response.data.data){
          this.bidPriceInfo.sorted = response.data.data.sorted;
          this.bidPriceInfo.cumulativeDecline = response.data.data.bjDecline;
          this.bidPriceInfo.finalAmount = response.data.data.bjTotal;
          this.tenderQuotation.hName = response.data.data.hName;
          console.log('-----------------------------')
          console.log(this.tenderQuotation.hName)
        }
      });
    },
    findProcurementPlanInfo(aid){
      console.log('333333333333333333333333333')
      console.log(aid)
      findProcurementPlan(aid).then(response=>{
        if(response.data && response.data.data){
          console.log('22222222222222222222222222222222222')
          this.tenderQuotation.aaCode = response.data.data.aaCode;
          console.log(this.tenderQuotation.aaCode)

          findBiddingList(this.bidForm.sid,this.bidForm.hid).then(response=>{
            this.loading2 = false;
            console.log('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
            console.log(response.data.data);
            console.log(response.data.data.length);
            if(response.data && response.data.data){
              this.biddingPriceList = response.data.data
              this.tenderQuotation.bjCount = this.biddingPriceList.length;
              if(response.data.data.length === 0){
                //出初始价
                this.tenderQuotation.sCode=this.bidPrice.sCode;
                const number = this.parseNumber('0');
                this.tenderQuotation.bjDecline = parseFloat(this.bidPriceInfo.cumulativeDecline) + (parseFloat(this.bidPrice.minDecline) * number);
                const totalPrice = parseFloat(this.bidPrice.startPrice) - parseFloat(this.tenderQuotation.bjDecline) * parseFloat(this.bidPrice.startPrice)/100;
                const decimalPlaces = this.bidPrice.decimalPlaces;
                this.tenderQuotation.bjTotal = this.roundNumber(totalPrice,decimalPlaces);

                console.log(this.tenderQuotation)
                addTenderQuotation(this.tenderQuotation).then(response=>{
                  console.log(response.data)
                  console.log('1111111111111111111wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww111111111111111111111111111111111111111')
                  if(response.data && response.data.code === 200){
                  }else{
                  }
                  this.findLastQuotation(this.bidForm.sid,this.bidForm.hid);
                  this.findTenderQuotationList(this.bidForm.sid,this.bidForm.hid);
                });

              }
            }
          });

        }
      });
    },
    findTenderQuotationList(sid,hid){
      findBiddingList(sid,hid).then(response=>{
        console.log(response.data)
        if(response.data && response.data.data){
          console.log('eeeeeeeeeeeeeeeeeeeeeeeeeeeeee')
          this.biddingPriceList = response.data.data;
          this.tenderQuotation.bjCount = this.biddingPriceList.length;
        }
      });
    },
    handlePriceInput(){
      console.log(this.bidPriceInfo.bidMultiple)
      const number = this.parseNumber(this.bidPriceInfo.bidMultiple);
      this.tenderQuotation.bjDecline = parseFloat(this.bidPriceInfo.cumulativeDecline) + (parseFloat(this.bidPrice.minDecline) * number);
      const totalPrice = parseFloat(this.bidPrice.startPrice) - parseFloat(this.tenderQuotation.bjDecline) * parseFloat(this.bidPrice.startPrice)/100;
      const decimalPlaces = this.bidPrice.decimalPlaces;
      this.tenderQuotation.bjTotal = this.roundNumber(totalPrice,decimalPlaces);
      this.bidPriceInfo.bidPriceTips = this.tenderQuotation.bjDecline + '  %' + '    报价：' + this.tenderQuotation.bjTotal;
      console.log(number)
      this.textColor = '#e6a23c';
      this.bidPriceInfo.submitText = '点击出价';
      if(this.bidPriceInfo.bidMultiple === ''){
        this.bidPriceInfo.bidPriceTips='';
      }
    },
    submitBidPrice(){
      console.log(sessionStorage.getItem("token"))
      if (sessionStorage.getItem("token") == null) {
        modal.alertWarning("注册并登录后再竞价")
        return;
      }
      const number = this.parseNumber(this.bidPriceInfo.bidMultiple);
      const tempBjDecline = parseFloat(this.bidPrice.minDecline) * number;
      if(tempBjDecline > this.bidPrice.maxDecline){
        modal.alertWarning("本次降幅超出每次最大降幅")
        return;
      }
      console.log(this.bidPriceInfo.bidMultiple)
      if(this.bidPriceInfo.bidMultiple == null || this.bidPriceInfo.bidMultiple === ''){
        modal.alertWarning("出价前请先在括号内输入整数")
        return;
      }
      const otherUKaiTime = this.bidPrice.uKaiTime;
      const now = new Date().getTime();
      const otherDate = new Date(otherUKaiTime).getTime();
      if(now < otherDate){
        modal.alertWarning("未到竞标时间")
        return;
      }
      const otherUKaiEndTime = this.bidPrice.uKaiEndTime;
      const otherEndDate = new Date(otherUKaiEndTime).getTime();
      if(now > otherEndDate){
        modal.alertWarning("竞价已结束！")
        return;
      }

      this.tenderQuotation.sCode=this.bidPrice.sCode;
      console.log(this.tenderQuotation)
      addTenderQuotation(this.tenderQuotation).then(response=>{
        console.log(response.data)
        if(response.data && response.data.code === 200){
          this.textColor = 'green';
          this.bidPriceInfo.submitText = '出价成功';
        }else{
          this.textColor = 'red';
          this.bidPriceInfo.submitText = '出价失败';
        }
        this.bidPriceInfo.bidMultiple=null;
        this.bidPriceInfo.bidPriceTips='';
        this.findLastQuotation(this.bidForm.sid,this.bidForm.hid);
        this.findTenderQuotationList(this.bidForm.sid,this.bidForm.hid);
      });
    },
    parseNumber(value) {
      if (value === '' || isNaN(value)) {
        return 0;
      }
      return parseInt(value);
    },
    // 限制只能输入数字和小数点
    validateNumberInput(event) {
      const charCode = event.which ? event.which : event.keyCode;
      if (charCode < 48 || charCode > 57) {
        event.preventDefault();
        return false;
      }
      return true;
    },
    // 四舍五入函数
    roundNumber(number, decimalPlaces) {
      // 处理非数字情况
      if (isNaN(number) || !isFinite(number)) {
        return "输入的不是有效数字";
      }
      // 处理小数位数为负数的情况
      if (decimalPlaces < 0) {
        decimalPlaces = 0;
      }
      // 使用toFixed方法进行四舍五入
      return number.toFixed(decimalPlaces);
    },
    calculateDecimalRatio(num1, num2) {
      // 验证输入是否为有效数字
      if (typeof num1 !== 'number' || typeof num2 !== 'number' || isNaN(num1) || isNaN(num2)) {
        throw new Error('两个参数都必须是有效数字');
      }
      // 处理除数为零的情况
      if (num2 === 0) {
        if (num1 === 0) {
          return NaN; // 0/0 是不确定的
        }
        return num1 > 0 ? Infinity : -Infinity; // 返回正无穷或负无穷
      }
      // 计算倍数
      const result = num1 / num2;
      // 处理浮点数精度问题，保留最多10位小数
      return parseFloat(result.toFixed(10));
    },
    // 开始倒计时
    startCountdown(endTimeParam = null) {
      // 清除现有的倒计时
      if (this.countdownInterval) {
        clearInterval(this.countdownInterval);
      }
      // 使用参数或输入框的值
      const targetTime = endTimeParam;
      if (!targetTime) {
        this.showNotification('请先设置结束时间！');
        return;
      }
      this.initialTime = new Date(targetTime).getTime();
      this.updateCountdown();
      // 每秒更新一次倒计时
      this.countdownInterval = setInterval(() => {
        this.updateCountdown();
      }, 1000);
      this.showNotification('正在倒计时');
    },

    // 刷新倒计时（接收新参数）
    refreshCountdown() {
      findBiddingRule(this.bidForm.sid,this.bidForm.hid).then(response=>{
        if(response.data && response.data.data){
          this.bidPrice = response.data.data;
          this.uKaiTime = this.bidPrice.uKaiTime;
          this.uKaiEndTime = this.bidPrice.uKaiEndTime;
          const otherUKaiTime = this.bidPrice.uKaiTime;
          this.tenderQuotation.sCode = this.bidPrice.sCode;
          let max = this.bidPrice.maxDecline;
          let min = this.bidPrice.minDecline;
          this.multiple = this.calculateDecimalRatio(max,min);

          // 在实际应用中，这里可以接收新的结束时间参数
          const now = new Date().getTime();
          const otherDate = new Date(this.uKaiTime).getTime();
          if(now > otherDate){
            this.startCountdown(this.uKaiEndTime);
          }else{
            this.showNotification('未到竞标时间');
          }
          //已刷新倒计时时间
        }
      });
    },
    // 更新倒计时显示
    updateCountdown() {
      const endTime = new Date(this.initialTime);
      const now = new Date();
      const difference = endTime - now;
      if (difference <= 0) {
        console.log('jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj')
        this.days = 0;
        this.hours = 0;
        this.minutes = 0;
        this.seconds = 0;
        this.progress = 0;
        this.message = '时间已到！';
        this.isEnd = true;
        this.showNotification('竞价结束！');
        clearInterval(this.countdownInterval);

        //最后再刷新竞价列表
        this.findLastQuotation(this.bidForm.sid,this.bidForm.hid);
        this.findTenderQuotationList(this.bidForm.sid,this.bidForm.hid);
        return;
      }

      this.isEnd = false;
      console.log('uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu')
      // 计算天、时、分、秒
      const totalSeconds = Math.floor(difference / 1000);
      this.days = Math.floor(totalSeconds / (3600 * 24));
      this.hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
      this.minutes = Math.floor((totalSeconds % 3600) / 60);
      this.seconds = Math.floor(totalSeconds % 60);

      this.getBiddingCount ++;
      //刷新竞价列表
      if(this.getBiddingCount % 5 === 0){
        findBiddingRule(this.bidForm.sid,this.bidForm.hid).then(response=>{
          if(response.data && response.data.data){
            this.bidPrice = response.data.data;
            this.uKaiTime = this.bidPrice.uKaiTime;
            this.uKaiEndTime = this.bidPrice.uKaiEndTime;
            const otherUKaiTime = this.bidPrice.uKaiTime;
            this.tenderQuotation.sCode = this.bidPrice.sCode;
            let max = this.bidPrice.maxDecline;
            let min = this.bidPrice.minDecline;
            this.multiple = this.calculateDecimalRatio(max,min);
            this.initialTime = new Date(this.uKaiEndTime).getTime();
          }
        });

        this.findLastQuotation(this.bidForm.sid,this.bidForm.hid);
        this.findTenderQuotationList(this.bidForm.sid,this.bidForm.hid);
      }
    },
    // 显示通知
    showNotification(text) {
      this.notificationText = text;
    },
    parseTime2(time, pattern){
      const newDate = new Date(time);
      newDate.setMinutes(newDate.getMinutes() + 30);
      return this.parseTime(newDate,pattern);
    },
    parseTime(time, pattern) {
      if (arguments.length === 0 || !time) {
        return null
      }
      const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
      let date
      if (typeof time === 'object') {
        date = time
      } else {
        if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
          time = parseInt(time)
        } else if (typeof time === 'string') {
          time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.[\d]{3}/gm), '');
        }
        if ((typeof time === 'number') && (time.toString().length === 10)) {
          time = time * 1000
        }
        date = new Date(time)
      }
      const formatObj = {
        y: date.getFullYear(),
        m: date.getMonth() + 1,
        d: date.getDate(),
        h: date.getHours(),
        i: date.getMinutes(),
        s: date.getSeconds(),
        a: date.getDay()
      }
      const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
        let value = formatObj[key]
        // Note: getDay() returns 0 on Sunday
        if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
        if (result.length > 0 && value < 10) {
          value = '0' + value
        }
        return value || 0
      })
      return time_str
    },
  },
  mounted() {
    // 设置默认结束时间为当前时间+24小时
    const defaultEndTime = new Date();
    defaultEndTime.setMinutes(defaultEndTime.getMinutes() + 30);
    this.uKaiEndTime = defaultEndTime;
  },
  beforeDestroy() {
    // 组件销毁前清除定时器
    if (this.countdownInterval) {
      clearInterval(this.countdownInterval);
    }
  }
}
</script>

<style>
* {
  margin: 0;
  padding: 0;
}

.my-input {
  font-weight: bold;
  height: 25px;
  width: 50px;
  padding-left: 10px;
  padding-right: 10px;
  border: 2px solid #000000;
  color: red;
  outline: none;
}
.my-input:focus {
  border-radius: 0px;
  border: 2px solid #000000;
}

.my-input-tips {
  color: red;
  font-weight: bold;
  margin-left: 10px;
  display: inline-block;
  width: 200px;
  height: 23px;
  line-height: 23px;
  border-top: none;
  border-right: none;
  border-bottom: 2px solid #3498db;
  border-left: none;
  outline: none;
}
.my-input-tips:focus {
  border-bottom: 2px solid #3498db;
}

.my-inline-block-span {
  font-weight: bold;
  margin-left: 10px;
  display: inline-block;
  width: 200px;
  height: 23px;
  border-bottom: 2px solid #3498db;
}

.bidding-grid-content {
  background-color: white;
  margin-top: 21px;
  width: 1360px;
  height: auto;
  margin-bottom: 30px;
  padding-left: 20px;
  padding-right: 20px;
}

.el-descriptions--medium.is-bordered .el-descriptions-item__cell {
  padding: 0 0px;
}

.el-date-editor.el-input, .el-date-editor.el-input__inner {
  width: 100%;
}

.el-input__inner {
  border: 0px solid #DCDFE6;
   height: 35px;
   line-height: 35px;
}

.el-textarea__inner {
  border: 0px solid #DCDFE6;
}

.tou {
  background: url('/public/images/bj.2c9500fa.png') 50%;
  background-size: 1920px 188px;
}

/*按钮颜色*/
.el-button--primary {
  color: #FFF;
  background-color: #0065B5;
  border-color: #0065B5;
}

body {
  background-color: #F9F9F9;
}
</style>
